package com.ruoyi.quality.controller;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.quality.domain.dto.InspectionItemDto;
import com.ruoyi.quality.domain.dto.InspectionTemplateDto;
import com.ruoyi.quality.service.InspectionItemService;
import com.ruoyi.quality.service.InspectionTemplateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.ParseException;

/**
 * 质检模板的服务
 */
@RestController
@RequestMapping("/inspectionTemplate")
public class InspectionTemplateController {
    @Autowired
    InspectionTemplateService inspectionTemplateService;


    @PostMapping("/getInspectionTemplateByPage")
    public R export(@RequestBody InspectionTemplateDto materialDto)
    {
        return R.ok(inspectionTemplateService.getInspectionTemplateByPage(materialDto));
    }

    @PostMapping("/addInspectionTemplate")
    public R addTest(@RequestBody InspectionTemplateDto materialDto) throws ParseException {
        inspectionTemplateService.addInspectionTemplate(materialDto);
        return R.ok("添加成功");
    }

    @PostMapping("/delInspectionTemplate")
    public R delTest(@RequestBody InspectionTemplateDto materialDto){
        inspectionTemplateService.delInspectionTemplate(materialDto);
        return R.ok("删除成功");
    }

    @PostMapping("/updateInspectionTemplate")
    public R updateTest(@RequestBody InspectionTemplateDto materialDto){
        inspectionTemplateService.updateInspectionTemplate(materialDto);
        return R.ok("锁定成功");
    }
    /**
     * 上传质检模板
     * @param materialDto
     * @return
     */
    @PostMapping("/updateInspectionTmpFile")
    public R updateInspectionTmpFile(@RequestBody InspectionTemplateDto materialDto){
        inspectionTemplateService.updateInspectionTmpFile(materialDto);
        return R.ok("锁定成功");
    }
}
